local Lua__ganran = fk.CreateSkill {

  name = "Lua__ganran",

}

Fk:loadTranslationTable{
    ["Lua__ganran"] = "感染",
    ["#Lua__ganran"] = "你可以选择一名其它角色，令其回合开始时失去一点体力并摸两张牌，若其回复了体力值，你获得其一张牌，并从牌堆获得一张【桃】。",
    ["#Lua__ganranECC"] = "感染",
    ["@@ganran_target"] = "感染",
    [":Lua__ganran"] = "出牌阶段限一次，你可以选择一名其它角色，令其回合开始时失去一点体力并摸两张牌，若其回复了体力值，你获得其一张牌，并从牌堆获得一张【桃】。",
    ["#ganran-target"] = "感染：选择一名其他角色",
    ["@ganran_used-turn"] = "感染",
    ["@ganran_target-turn"] = "感染",
    
}

Lua__ganran:addEffect("active", {
  anim_type = "control",
  prompt = "#Lua__ganran",
  can_use = function(self, player)
      return player:usedSkillTimes(Lua__ganran.name, Player.HistoryPhase) == 0 
  end,
  card_num = 0,
  target_filter = function(self, player, to_select, selected)
      return #selected == 0 and to_select ~= player
  end,
  target_num = 1,
  on_use = function(self, room, effect)
      local player = effect.from
      local target = effect.tos[1]
      room:setPlayerMark(target, "@@ganran_target", 1)
  end,
})

Lua__ganran:addEffect(fk.TurnStart, {
    anim_type = "control",
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
      if not player:hasSkill(Lua__ganran.name) then return false end
      return  target:getMark("@@ganran_target") > 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:loseHp(target, 1, Lua__ganran.name)
        target:drawCards(2, Lua__ganran.name) 
    end,
})
Lua__ganran:addEffect(fk.HpRecover, {
    anim_type = "control",
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        if not player:hasSkill(Lua__ganran.name) then return false end
        if not target:isNude() then
          return  target:getMark("@@ganran_target") > 0
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(target, "@@ganran_target", 0)
        local card = room:askToChooseCard(player, {
            target = target,
            flag = "he",
            skill_name = Lua__ganran.name,
        })

        if card then
            room:obtainCard(player, card, false, fk.ReasonPrey)
        end
        local cards = table.filter(room.draw_pile, function (id)
					return Fk:getCardById(id).name == "peach"
				end)
				if #cards > 0 then
					local card = Fk:getCardById(cards[1])
					room:obtainCard(player, card, false, fk.ReasonPrey)
				end
    end,
})
Lua__ganran:addEffect(fk.TurnEnd, {
    anim_type = "control",
    mute = true,
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        if not player:hasSkill(Lua__ganran.name) then return false end
        return target:getMark("@@ganran_target") > 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(target, "@@ganran_target", 0)
    end,
})

return Lua__ganran